package novel.enums;

/**
 * @Author:xdw
 * @Date:Created in 下午 5:412019/3/7 0007
 * @described:
 * @Modified By:
 */
public enum NovelSpiderEnum {
    BI_QU_GE(1,"www.biquge.tw"),
    DING_DIAN_WX(2,"www.23wx.cc"),
    QU_GE(3,"www.qb5200.tw"),
    KAN_SHU_ZHONG(4,"www.kanshuzhong.com");

    private Integer id;
    private String url;

    private NovelSpiderEnum(Integer id,String url){
        this.id=id;
        this.url=url;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public static NovelSpiderEnum getEnumById(Integer id){
        switch (id){
            case 1:return  BI_QU_GE;
            case 2:return DING_DIAN_WX;
            default:throw new RuntimeException("id"+id+"是不被支持的小说网站");
        }
    }

    public static NovelSpiderEnum getEnumByUrl(String url){
        for (NovelSpiderEnum spiderEnum:values()){
            if(url.contains(spiderEnum.url)){
                return spiderEnum;
            }
        }
        throw new RuntimeException("url"+url+"是不被支持的小说网站");
    }


}
